<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@   taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html >
<html>
<head>
	<base href="<%=basePath%>">
     <meta charset="utf-8">

        <title> Lexy - 发表文章 </title>

　　<meta name="keywords" content="lexy,Lexyui,lexyui,lexy博客"> 
        <meta name="description" content="lexy 博客站">
        <meta name="author" content="lexy">
        <meta name="robots" content="noindex, nofollow">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

        <!-- Icons -->
        <!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
        <link rel="shortcut icon" href="plugins/v2/img/favicons/favicon.png">

        <link rel="icon" type="image/png" href="plugins/v2/img/favicons/favicon-16x16.png" sizes="16x16">
        <link rel="icon" type="image/png" href="plugins/v2/img/favicons/favicon-32x32.png" sizes="32x32">
        <link rel="icon" type="image/png" href="plugins/v2/img/favicons/favicon-96x96.png" sizes="96x96">
        <link rel="icon" type="image/png" href="plugins/v2/img/favicons/favicon-160x160.png" sizes="160x160">
        <link rel="icon" type="image/png" href="plugins/v2/img/favicons/favicon-192x192.png" sizes="192x192">

        <link rel="apple-touch-icon" sizes="57x57" href="plugins/v2/img/favicons/apple-touch-icon-57x57.png">
        <link rel="apple-touch-icon" sizes="60x60" href="plugins/v2/img/favicons/apple-touch-icon-60x60.png">
        <link rel="apple-touch-icon" sizes="72x72" href="plugins/v2/img/favicons/apple-touch-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="76x76" href="plugins/v2/img/favicons/apple-touch-icon-76x76.png">
        <link rel="apple-touch-icon" sizes="114x114" href="plugins/v2/img/favicons/apple-touch-icon-114x114.png">
        <link rel="apple-touch-icon" sizes="120x120" href="plugins/v2/img/favicons/apple-touch-icon-120x120.png">
        <link rel="apple-touch-icon" sizes="144x144" href="plugins/v2/img/favicons/apple-touch-icon-144x144.png">
        <link rel="apple-touch-icon" sizes="152x152" href="plugins/v2/img/favicons/apple-touch-icon-152x152.png">
        <link rel="apple-touch-icon" sizes="180x180" href="plugins/v2/img/favicons/apple-touch-icon-180x180.png">
        <!-- END Icons -->

        <!-- Stylesheets -->
        <!-- Web fonts -->
       <!--  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400italic,600,700%7COpen+Sans:300,400,400italic,600,700"> -->


		<!-- Page JS Plugins CSS -->
		
	    <link rel="stylesheet" href="plugins/v2/js/plugins/select2/select2.min.css">
    	<link rel="stylesheet" href="plugins/v2/js/plugins/select2/select2-bootstrap.min.css">
    	<link rel="stylesheet" href="plugins/v2/js/plugins/jquery-tags-input/jquery.tagsinput.min.css">
		
        <link rel="stylesheet" href="plugins/v2/js/plugins/summernote/summernote.min.css">
        <link rel="stylesheet" href="plugins/v2/js/plugins/simplemde/simplemde.min.css">

		
        <!-- Bootstrap and OneUI CSS framework -->
        <link rel="stylesheet" href="plugins/v2/css/bootstrap.min.css">
        <link rel="stylesheet" id="css-main" href="plugins/v2/css/oneui.css">

        <!-- You can include a specific file from css/themes/ folder to alter the default color theme of the template. eg: -->
        <!-- <link rel="stylesheet" id="css-theme" href="plugins/v2/css/themes/flat.min.css"> -->
        <!-- END Stylesheets -->
        
        <style type="text/css">
        .content.content-boxed {
		    max-width: 95%;
		}
		.block-content.block-content-narrow {
		    padding-left: 5%;
		    padding-right: 5%;
		}
        
        </style>
        
    </head>
    <body>
        <div id="page-container" class="sidebar-l sidebar-mini sidebar-o side-scroll header-navbar-fixed">
            <!-- Side Overlay-->
            <jsp:include page="com/_right_sidebar.jsp"></jsp:include>
            <!-- END Side Overlay -->

            <!-- Sidebar -->
           <jsp:include page="com/_left_sidebar.jsp"></jsp:include>
            <!-- END Sidebar -->
            

            <!-- Header -->
            <jsp:include page="com/_top_tools.jsp"></jsp:include>
            <!-- END Header -->

            <!-- Main Container -->
            <main id="main-container">
            		<section class="content content-boxed">
						<div class="row">
							<div class="col-md-7">
								<!-- New Topic -->
		                    <div class="block">
		                        <div class="block-header bg-gray-lighter">
		                            <h3 class="block-title"><i class="fa fa-plus"></i> 发表新文章</h3>
		                        </div>
		                        <div class="block-content block-content-full block-content-narrow">
		                            <form class="form-horizontal  push-10-t" id="blog_content_form"  action="v2/blog/insertBlog" onsubmit="return false;">
		                                <div class="form-group">
		                                    <div class="col-md-7">
		                                        <div class="form-material form-material-primary">
		                                            <input class="form-control" type="text" id="title" name="title" placeholder="请填写主题标题...">
		                                            <label for="title">主题标题 <span class="text-danger">*</span></label>
		                                        </div>
		                                    </div>
		                                </div>
		                                <div class="form-group">
		                                    <div class="col-md-7">
		                                        <div class="form-material form-material-primary">
		                                            <input class="form-control" type="text" id="desc" name="desc" placeholder="请填写主题描述...">
		                                            <label for="desc">主题描述</label>
		                                        </div>
		                                    </div>
		                                </div>
		                                <div class="form-group">
		                                    <div class="col-md-7">
		                                        <!-- Select2 (.js-select2 class is initialized in App() -> uiHelperSelect2()) -->
		                                        <!-- For more info and examples you can check out https://github.com/select2/select2 -->
		                                        <div class="form-material form-material-primary">
		                                            <select class="js-select2 form-control" id="type" name="type" style="width: 100%;" data-placeholder="请选择主题类型...">
		                                                <option></option>
		                                                <option value="1">- 博客</option>
		                                                <option value="2">- 图文</option>
		                                            </select>
		                                            <label for="type">主题类型 <span class="text-danger">*</span></label>
		                                        </div>
		                                    </div>
		                                </div>
		                                <div class="form-group">
		                                    <div class="col-md-7">
		                                        <!-- jQuery Tags Input (.js-tags-input class is initialized in App() -> uiHelperTagsInput()) -->
		                                        <!-- For more info and examples you can check out https://github.com/xoxco/jQuery-Tags-Input -->
		                                        <div class="form-material form-material-primary">
		                                            <input class="js-tags-input form-control" type="text" id="topic-tags" name="topic-tags" value="Question">
		                                            <label for="topic-tags">主题标签 <span class="text-danger">*</span></label>
		                                        </div>
		                                    </div>
		                                </div>
		                                <div class="form-group">
		                                    <div class="col-xs-12">
							                    <!-- <div class="block"> -->
					                            <div class="form-material form-material-primary">
						                            <!-- Summernote Container -->
						                            <input type="hidden" id="content" name="content">
						                            <div class="js-summernote">Hello Summernote!</div>
						                        	<label for="topic-tags">主题内容</label>
							                    </div>
		                                    </div>
		                                </div>
		                                <input type="hidden" id="status" name="status" />
		                                <input type="hidden" id="serialId" name="serialId" value="${serialId}"/>
		                            </form>
		                        </div>
		                    </div>
		                    <!-- END New Topic -->
		                    </div>
							<div class="col-md-5">
								<div class="block ">
		                                <div class="block-header bg-gray-lighter">
		                                    <h3 class="block-title">设置封面</h3>
		                                </div>
		                                <div class="block-content block-content-full block-content-narrow">
		                                    <!-- <form class="form-horizontal push-10-t push-10" >
		                                        <div class="form-group">
		                                            <div class="col-xs-12">
		                                                <div class="form-material">
		                                                    <div style="height:auto;width:100%;max-height:200px;">
							                                	<img src="content/admin/timg.jpg" id="blog_img" style="width:100%;" alt=""> 
							                                </div>
		                                                    <label for="thumbnail">预览</label>
		                                                </div>
		                                            </div>
		                                        </div>
		                                        <div class="form-group">
		                                            <div class="col-xs-12">
		                                                <div class="form-material">
		                                                    <input class="form-control" id="fileToUpload" type="file" name="upfile"><br>
		                                                    <label for="fileToUpload">文件域</label>
		                                                </div>
		                                            </div>
		                                        </div>
		                                    </form> -->
		                                    
		                                    <jsp:include page="fullavatareditor.jsp"></jsp:include>
		                                </div>
		                            </div>
							</div>
							
							<div class="col-md-4">
								<div class="block ">
		                                <div class="block-header bg-gray-lighter">
		                                    <h3 class="block-title">操作</h3>
		                                </div>
		                                <div class="block-content block-content-full block-content-narrow">
		                                    <form class="form-horizontal push-10-t push-10" onsubmit="return false;" >
		                                        <div class="form-group">
		                                            <div class="col-xs-12">
		                                                <div class="form-material">
		                                                    <div class="col-sm-12">
						                                    <label class="css-input css-radio css-radio-warning push-10-r">
						                                          <input type="radio" name="push_status" value="0" checked="checked"><span></span> 公开
						                                    </label>
						                                    <label class="css-input css-radio css-radio-warning">
						                                          <input type="radio" name="push_status" value="1"><span></span> 私密(仅自己可见)
						                                    </label>
						                                </div>
		                                                    <label for="push_status">发布状态</label>
		                                                </div>
		                                            </div>
		                                        </div>
		                                        <div class="form-group">
				                                    <div class="col-xs-12">
				                                        <button id="push_blog" class="btn btn-sm btn-primary" type="type"><i class="fa fa-plus"></i> 发布主题</button>
				                                        <button class="btn btn-sm btn-default" type="button"><i class="fa fa-eye"></i> 预览</button>
				                                        <button id="add_blog" class="btn btn-sm btn-default" type="button"><i class="fa fa-floppy-o"></i> 保存至草稿箱</button>
				                                    </div>
				                                </div>
		                                    </form>
		                                </div>
		                            </div>
							</div>
						</div>            
				</section>
            	
            </main>
            <!-- END Main Container -->
        </div>
        <!-- END Page Container -->

        <!-- Apps Modal -->
        <!-- Opens from the button in the header -->
        <div class="modal fade" id="apps-modal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-sm modal-dialog modal-dialog-top">
                <div class="modal-content">
                    <!-- Apps Block -->
                    <div class="block block-themed block-transparent">
                        <div class="block-header bg-primary-dark">
                            <ul class="block-options">
                                <li>
                                    <button data-dismiss="modal" type="button"><i class="si si-close"></i></button>
                                </li>
                            </ul>
                            <h3 class="block-title">Apps</h3>
                        </div>
                        <div class="block-content">
                            <div class="row text-center">
                                <div class="col-xs-6">
                                    <a class="block block-rounded" href="base_pages_dashboard.html">
                                        <div class="block-content text-white bg-default">
                                            <i class="si si-speedometer fa-2x"></i>
                                            <div class="font-w600 push-15-t push-15">Backend</div>
                                        </div>
                                    </a>
                                </div>
                                <div class="col-xs-6">
                                    <a class="block block-rounded" href="frontend_home.html">
                                        <div class="block-content text-white bg-modern">
                                            <i class="si si-rocket fa-2x"></i>
                                            <div class="font-w600 push-15-t push-15">Frontend</div>
                                        </div>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- END Apps Block -->
                </div>
            </div>
        </div>
        <!-- END Apps Modal -->

        <!-- OneUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock, Appear, CountTo, Placeholder, Cookie and App.js -->
        <script src="plugins/v2/js/core/jquery.min.js"></script>
        <script src="plugins/v2/js/core/bootstrap.min.js"></script>
        <script src="plugins/v2/js/core/jquery.slimscroll.min.js"></script>
        <script src="plugins/v2/js/core/jquery.scrollLock.min.js"></script>
        <script src="plugins/v2/js/core/jquery.appear.min.js"></script>
        <script src="plugins/v2/js/core/jquery.countTo.min.js"></script>
        <script src="plugins/v2/js/core/jquery.placeholder.min.js"></script>
        <script src="plugins/v2/js/core/js.cookie.min.js"></script>
        <script src="plugins/v2/js/app.js"></script>
        <script src="plugins/v2/js/pub.js"></script>
        
        <!-- Page JS Plugins -->
        <script src="plugins/v2/js/plugins/summernote/summernote.min.js"></script>
        <script src="plugins/v2/js/plugins/select2/select2.full.min.js"></script>
        <script src="plugins/v2/js/plugins/jquery-tags-input/jquery.tagsinput.min.js"></script>
        <script>
            jQuery(function () {
                // Init page helpers (Summernote + CKEditor + SimpleMDE plugins)
                App.initHelpers(['select2', 'tags-inputs','summernote']);
                
                $("#push_blog").click(function(){
                	saveBlogContent("1");
                })
                $("#add_blog").click(function(){
                	saveBlogContent("0");
                })
                
            });
            
            
            
            
            
            
            
            
            
            function saveBlogContent(type){
            	
            	
            	
            	var shtml = $('.js-summernote').summernote('code');
        		if(shtml==null || shtml=="" || shtml==" "){
        			alert("请输入主题内容...");
        			return;
        		}
            	var formVal = $("#blog_content_form").serializeJsonStr();
            	//formVal["content"]=shtml;
            	formVal = $.parseJSON( formVal );
            	
            	formVal['content']=shtml;
            	formVal['pushState'] = type;
            	console.log(formVal);
            	var reqStr = {"reqStr":JSON.stringify(formVal)};
            	console.log(reqStr);
            	var result = doPost("v2/blog/insertBlog" , reqStr);
            	console.log(result);
            	if("200"==result.code){
            		
            		if(confirm("发布成功,前往查看该博客?")){
            			window.location.href=(result.detail.addr+"?id="+result.detail.id);
            		}
            	}else{
            		alert(result.description);
            	}
            }
            
            
            
            
            
        </script>
    </body>
</html>